﻿using System;
using System.Web.Mvc;
using Icms.Core.Model;
using Icms.Core.Service;
using Icms.WebUI.Builder;
using Icms.WebUI.Dto;

namespace Icms.WebUI.Controllers
{
    public class RegistrationController: Cruder<Case, RegistrationInput>
    {
        private new readonly ICaseService s;
        public RegistrationController(ICaseService s, IMapper<Case, RegistrationInput> v) : base(s, v)
        {
            this.s = s;
        }

        public override ActionResult Index()
        {
            ViewBag.Case = new Guid(Request["CaseId"]).Case();
            return View();
        }

        public override ActionResult Edit(Guid id, string msg = null)
        {
            var o = s.Get(id);
            var input = ve.MapToInput(o);
            if (string.IsNullOrEmpty(input.Title)) input.Title = s.GetTitle(id);
            return View(EditView, input);
        }

        public ActionResult Summary(Guid id)
        {
            return View(s.Get(id));
        }
    }
}